﻿Public Class FormWarehouseCHPList
    Dim objCA As New clsCPCK
    Dim txt As TextBox
    Private Sub FormWarehouseCHPList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim startDate As String = Date.Now.AddDays(-1).ToShortDateString()
        txtStartDate.Text = startDate
        Dim endDate As String = Date.Now.ToShortDateString()
        txtEndDate.Text = endDate
    End Sub

    Private Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
        Dim dtCacheArea As DataTable = objCA.getList(txtProdId.Text.Trim(), cmbWHNo.Text,
                                    txtStartDate.Text.Trim(),
                                    txtEndDate.Text.Trim())
        dtCacheArea.Columns.Add("status_name")
        dtCacheArea.Columns.Add("area_name")
        If dtCacheArea.Rows.Count > 0 Then
            For Each row As DataRow In dtCacheArea.Rows
                If row("status") = "0" Then
                    row("status_name") = "在库"
                Else
                    row("status_name") = "已出库"
                End If
                If DBNull.Value.Equals(row("area")) = False Then
                    If row("area") = "ZAGZ01A" Then
                        row("area_name") = "隔震成品库_A区"
                    End If
                    If row("area") = "ZAGZ01B" Then
                        row("area_name") = "隔震成品库_B区"
                    End If
                    If row("area") = "ZAGZ01C" Then
                        row("area_name") = "隔震成品库_C区"
                    End If
                    If row("area") = "ZAGZ01D" Then
                        row("area_name") = "隔震成品库_D区"
                    End If
                    If row("area") = "ZAGZ01E" Then
                        row("area_name") = "隔震成品库_E区"
                    End If
                Else
                    row("area_name") = ""
                End If
            Next
        End If
        dgv.AutoGenerateColumns = False
        dgv.DataSource = dtCacheArea
        lblCount.Text = dgv.Rows.Count
    End Sub

    Private Sub txt_MouseClick(sender As Object, e As MouseEventArgs) Handles txtStartDate.MouseClick, txtEndDate.MouseClick
        txt = CType(sender, TextBox)
        DateNavigator1.Left = txt.Left
        DateNavigator1.Top = txt.Location.Y + txt.Height
        DateNavigator1.Visible = True
    End Sub

    Private Sub DateNavigator1_DateTimeChanged(sender As Object, e As EventArgs) Handles DateNavigator1.DateTimeChanged
        txt.Text = DateNavigator1.DateTime.ToShortDateString()
        DateNavigator1.Visible = False
    End Sub

End Class